/**
 *	@project:	kybernetes
 *	@author:	D.Toepel
 *	@note:		---
 *	
 *	Copyright (C) 2009  D.Toepel <de.dtools> {at} <gmail> {dot} <com>
 *	
 *	This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *	
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *	
 */
package dt.htwk.core;

import java.awt.*;
import javax.swing.*;

import dt.htwk.res.Resource;

/**
 * Statusbar mit Zeit und Ereignisanzeige
 * @author DToepel
 *
 */
public class KCStatusBar extends JPanel{
	
	private static final long serialVersionUID = 1L;
	private static JLabel statusLabel1;
	private JLabel statusLabel2;
	private JLabel statusLabel3;
	private static JLabel connectLabel;
	private Resource res = new Resource();
	
	public KCStatusBar(){
		super();
		initGUI();
	}
	
	public static void setStatusMessage(String message){
		KCStatusBar.statusLabel1.setText(message);
	}
	
	public void setTime(String[] time){
		this.statusLabel3.setText(time[0]);
		this.statusLabel3.setToolTipText(time[1]);
	}
	
	public static void setConnected(){
		connectLabel.setIcon(Resource.connectIcon);
		connectLabel.setToolTipText("Verbindung zum Server hergestellt!");
	}
	
	public static void setDisconnectedA(){
		connectLabel.setIcon(Resource.disconnectAIcon);
		connectLabel.setToolTipText("Server ereichbar, aber keine Verbindung!");
	}
	
	public static void setDisconnectedB(){
		connectLabel.setIcon(Resource.disconnectBIcon);
		connectLabel.setToolTipText("Keine Verbindung zum Server!");
	}
	
	private void initGUI(){
				
		this.setLayout(new BorderLayout());
		this.setOpaque(true);
		this.setForeground(res.lightGray);
		this.setBackground(res.darkMarineBlue);
		this.setPreferredSize(new Dimension(150,23));
		{
			connectLabel = new JLabel(res.disconnectIcon);
			connectLabel.setHorizontalAlignment(SwingConstants.LEFT);
			connectLabel.setForeground(new java.awt.Color(230,230,230));
			connectLabel.setBorder(BorderFactory.createEmptyBorder(2,5,2,10));
			connectLabel.setToolTipText("Keine Verbindung zum Server!");
		}
		{
			statusLabel1 = new JLabel("Kybernetes Cup");
			statusLabel1.setHorizontalAlignment(SwingConstants.LEFT);
			statusLabel1.setForeground(new java.awt.Color(230,230,230));
			statusLabel1.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
		}
		{
			statusLabel2 = new JLabel("(c)2009 D.Toepel");
			statusLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
			statusLabel2.setForeground(new java.awt.Color(230,230,230));
			statusLabel2.setEnabled(false);
			statusLabel2.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
		}
		{
			statusLabel3 = new JLabel();
			statusLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
			statusLabel3.setForeground(new java.awt.Color(230,230,230));
			statusLabel3.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
		}
		JPanel jp = new JPanel(new BorderLayout());
		jp.setOpaque(false);
		jp.add(connectLabel, BorderLayout.LINE_START);
		jp.add(statusLabel1, BorderLayout.CENTER);
		
		this.add(jp, BorderLayout.LINE_START);
		this.add(statusLabel2, BorderLayout.CENTER);
		this.add(statusLabel3, BorderLayout.LINE_END);
	}
	
}
